<?php

use app\common\enum\OrderType as OrderTypeEnum;

?>

<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title a m-cf">创建活动</div>
                </div>
                <div class="widget-body am-fr">
                    <div class="page_toolbar am-margin-bottom am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <?php if (checkPrivilege('activity.manba/add')): ?>
                                                                                <div class="am-btn-group am-btn-group-xs">
                                                                                    <a class="am-btn am-btn-default am-btn-success"
                                                                                       href="<?= url('activity.manba/add') ?>">
                                                                                        <span class="am-icon-plus"></span> 创建
                                                                                    </a>
                                                                                </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-9">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <select name="shop_id"
                                                data-am-selected="{searchBox: 1, btnSize: 'sm', placeholder: '所属门店', maxHeight: 400}">
                                            <option value=""></option>
                                            <?php if (isset($shopList)): foreach ($shopList as $shop): ?>
                                                <option value="<?= $shop['shop_id'] ?>"
                                                    <?= $request->get('shop_id') == $shop['shop_id'] ? 'selected' : '' ?>>
                                                    <?= $shop['shop_name'] ?>
                                                </option>
                                            <?php endforeach; endif; ?>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search"
                                                   placeholder="请输入用户名/门店名称"
                                                   value="<?= $request->get('search') ?>">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>商品名称</th>
                                <th>规定人数</th>
                                <th>标题</th>
                                <th>简介</th>
                                <th>手机号</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle"><?= $item['goods_name'] ?></td>
                                    <td class="am-text-middle"><?= $item['num'] ?></td>
                                    <td class="am-text-middle"><?= $item['title'] ?></td>
                                    <td class="am-text-middle"><?= $item['content'] ?></td>

                                    <td class="am-text-middle"><?= $item['phone'] ?></td>
                                    <!--                                    <td class="am-text-middle">-->
                                    <!--                                        <span class="am-badge am-badge-secondary">-->
                                    <!--                                           --><?//= $item['order_type']['text'] ?>
                                    <!--                                       </span>-->
                                    <!--                                    </td>-->
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">

                                            <a  class="nmabafs" tr="<?= $item['id'] ?>">

                                                <i class="am-icon-pencil"></i> 报名列表
                                            </a>
                                            <?php if (checkPrivilege('activity.manba/edit')): ?>
                                                <a href="<?= url('activity.manba/edit', ['id' => $item['id']]) ?>">
                                                    <i class="am-icon-pencil"></i> 编辑
                                                </a>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('activity.manba/delete')): ?>
                                                <a href="javascript:void(0);"
                                                   class="item-delete tpl-table-black-operation-del"
                                                   data-id="<?= $item['id'] ?>">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="9" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total()?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="assets/common/js/vue.min.js"></script>
<script src="assets/common/js/ddsort.js"></script>
<script src="assets/common/plugins/umeditor/umeditor.config.js?v=<?= $version ?>"></script>
<script src="assets/common/plugins/umeditor/umeditor.min.js"></script>

<script src="assets/store/js/goods.spec.js?v=<?= $version ?>"></script>
<script src="assets/store/js/select.data.js?v=<?= $version ?>"></script>
<script>
    $(function () {
        // 删除元素
        var url = "<?= url('activity.manba/delete') ?>";
        $('.item-delete').delete('id', url, '删除后不可恢复，确定要删除吗？');
        // 门店列表

        $('.j-selectUser').click(function () {
            var $userList = $('.user-list');
            $.selectData({
                title: '选择用户',
                uri: 'shop/lists',
                dataIndex: 'goods_id',
                done: function (data) {
                    console.log(data)

                    $('.manba').attr('src',data[0]['goods_image'])
                    $('.goods_id').val(data[0]['goods_id'])
                    $('.goods_image').val(data[0]['goods_image'])
                    var goods = [data[0]];
                    $userList.html(template('tpl-user-item', goods));
                }
            });
        })


        $('.nmabafs').click(function () {
            var $userList = $('.user-list');
            var goods_idd=$(this).attr('tr')
            $.selectData({
                title: '选择门店',
                uri: 'shop/acvt?id='+goods_idd,
                dataIndex: 'goods_id',
                done: function (data) {
                    console.log(data)
                    // $.ajax({
                    //     //几个参数需要注意一下
                    //     type: "POST",//方法类型
                    //     dataType: "json",//预期服务器返回的数据类型
                    //     url: "index.php?s=/store/data.shop/data" ,//url
                    //     data: {
                    //         data:data ,
                    //         goods_id:goods_idd,
                    //
                    //     },
                    //     success: function (result) {
                    //
                    //     },
                    //
                    // });
                }
            });
        })

    });
</script>

